home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Internet / HTMLGate 12.2.1B / htmlgate.exe / {app} / Cookies / cookie8.txt < prev    next >
Encoding:
Text File  |  2000-07-12  |  1.9 KB  |  57 lines

  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!--
  3. var caution = false
  4.  
  5. function setCookie(name, value, expires, path, domain, secure) {
  6.         var curCookie = name + "=" + escape(value) +
  7.                 ((expires) ? "; expires=" + expires.toGMTString() : "") +
  8.                 ((path) ? "; path=" + path : "") +
  9.                 ((domain) ? "; domain=" + domain : "") +
  10.                 ((secure) ? "; secure" : "")
  11.         if (!caution || (name + "=" + escape(value)).length <= 4000)
  12.                 document.cookie = curCookie
  13.         else
  14.                 if (confirm("Cookie exceeds 4KB and will be cut!"))
  15.                         document.cookie = curCookie
  16. }
  17.  
  18. function getCookie(name) {
  19.         var prefix = name + "="
  20.         var cookieStartIndex = document.cookie.indexOf(prefix)
  21.         if (cookieStartIndex == -1)
  22.                 return null
  23.         var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
  24.         if (cookieEndIndex == -1)
  25.                 cookieEndIndex = document.cookie.length
  26.         return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
  27. }
  28.  
  29. function deleteCookie(name, path, domain) {
  30.         if (getCookie(name)) {
  31.                 document.cookie = name + "=" + 
  32.                 ((path) ? "; path=" + path : "") +
  33.                 ((domain) ? "; domain=" + domain : "") +
  34.                 "; expires=Thu, 01-Jan-70 00:00:01 GMT"
  35.         }
  36. }
  37.  
  38. function fixDate(date) {
  39.         var base = new Date(0)
  40.         var skew = base.getTime()
  41.         if (skew > 0)
  42.                 date.setTime(date.getTime() - skew)
  43. }
  44. var now = new Date()
  45. fixDate(now)
  46. now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
  47. var visits = getCookie("counter")
  48. if (!visits)
  49.         visits = 1
  50. else
  51.         visits = parseInt(visits) + 1
  52. setCookie("counter", visits, now)
  53. document.write("You have been here " + visits + " time(s).")
  54.  
  55. //-->
  56. </SCRIPT>
  57.